<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="theme-color" content="#33474d">
	<title>rsync错误二则、排错过程及解决办法 | 失落的乐章</title>
	<link rel="stylesheet" href="/css/style.css" />
	
      <link rel="alternate" href="/atom.xml" title="失落的乐章" type="application/atom+xml">
    
</head>

<body>

	<header class="header">
		<nav class="header__nav">
			
				<a href="/archives" class="header__link">Archive</a>
			
				<a href="/tags" class="header__link">Tags</a>
			
				<a href="/atom.xml" class="header__link">RSS</a>
			
		</nav>
		<h1 class="header__title"><a href="/">失落的乐章</a></h1>
		<h2 class="header__subtitle">技术面前，永远都是学生。</h2>
	</header>

	<main>
		<article>
	
		<h1>rsync错误二则、排错过程及解决办法</h1>
	
	<div class="article__infos">
		<span class="article__date">2017-10-12</span><br />
		
		
			<span class="article__tags">
			  	<a class="article__tag-link" href="/tags/Linux/">Linux</a>
			</span>
		
	</div>

	

	
		<p><figure class="figure"><img src="https://github.com/hcldirgit/image/blob/master/rsync%E9%94%99%E8%AF%AF%E4%BA%8C%E5%88%99%E3%80%81%E6%8E%92%E9%94%99%E8%BF%87%E7%A8%8B%E5%8F%8A%E8%A7%A3%E5%86%B3%E5%8A%9E%E6%B3%95/01.png?raw=true" alt=""></figure></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div></pre></td><td class="code"><pre><div class="line"><span class="meta">#!/bin/bash</span></div><div class="line"><span class="comment">#</span></div><div class="line"><span class="comment">#created by zhaopeiwu @ 2015-04-20</span></div><div class="line"><span class="comment">#FOR control the size of error log of apache</span></div><div class="line">PATH=/usr/<span class="built_in">local</span>/sbin:/usr/<span class="built_in">local</span>/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/<span class="built_in">local</span>/apache2/bin:/usr/<span class="built_in">local</span>/mysql/bin</div><div class="line"><span class="built_in">export</span> PATH</div><div class="line"></div><div class="line">log_path=<span class="string">"/usr/local/apache2/logs/"</span></div><div class="line">log_size=`du -s <span class="variable">$log_path</span>/error_log|cut -f 1`</div><div class="line"><span class="keyword">if</span> [ <span class="variable">$log_size</span> -gt 100000 ];</div><div class="line"><span class="keyword">then</span></div><div class="line">    mv <span class="variable">$log_path</span>/error_log <span class="variable">$log_path</span>/error_log_`date +%Y%m%d`;</div><div class="line">    touch <span class="variable">$log_path</span>/error_log;</div><div class="line"><span class="keyword">fi</span></div><div class="line"></div><div class="line">num_del=`ls -t <span class="variable">$log_path</span>/error*|wc -l`</div><div class="line"><span class="keyword">if</span> [ <span class="variable">$num_del</span> -gt 4 ];</div><div class="line"><span class="keyword">then</span></div><div class="line">    ls -t <span class="variable">$log_path</span>/error*|tail -$[<span class="variable">$num_del</span>-2]|xargs -i rm -f &#123;&#125; 2 &gt; /dev/null</div><div class="line"><span class="keyword">fi</span></div><div class="line"></div><div class="line"><span class="built_in">exit</span> 0</div></pre></td></tr></table></figure>
	

	
		<span class="different-posts"><a href="/2017/10/12/1. Linux 基础/68. rsync错误二则、排错过程及解决办法/" onclick="window.history.go(-1); return false;">⬅️ Go back </a></span>

	

</article>

	</main>

	<footer class="footer">
	<div class="footer-content">
		
	      <div class="footer__element">
	<p>Hi there, <br />welcome to my Blog glad you found it. Have a look around, will you?</p>
</div>

	    
	      <div class="footer__element">
	<h5>Check out</h5>
	<ul class="footer-links">
		<li class="footer-links__link"><a href="/archives">Archive</a></li>
		
		  <li class="footer-links__link"><a href="/atom.xml">RSS</a></li>
	    
		<li class="footer-links__link"><a href="/about">about page</a></li>
		<li class="footer-links__link"><a href="/tags">Tags</a></li>
		<li class="footer-links__link"><a href="/categories">Categories</a></li>
	</ul>
</div>

	    

		<div class="footer-credit">
			<span>© 2017 失落的乐章 | Powered by <a href="https://hexo.io/">Hexo</a> | Theme <a href="https://github.com/HoverBaum/meilidu-hexo">MeiliDu</a></span>
		</div>

	</div>


</footer>



</body>

</html>
